CREATE TABLE [dbo].[Tb_Biliotecas]
(
[idbiblioteca] [int] NOT NULL IDENTITY(1, 1),
[Nombre] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[NroReconocimientoConabip] [int] NOT NULL,
[Categoria] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Direccion] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Barrio] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Localidad] [int] NOT NULL,
[Departamento] [int] NULL,
[Provincia] [int] NOT NULL,
[CodigoPostal] [int] NOT NULL,
[Telefono] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Fax] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[EMAIL] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[PaginaWeb] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Ubicacion] [int] NOT NULL,
[FechaFundacion] [datetime] NOT NULL,
[FechaReFundacion] [datetime] NULL,
[AñosAntiguedad] [int] NOT NULL,
[ApoderadoLegal] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TienePersoneriaJuridica] [int] NOT NULL,
[NroPersoneria] [int] NULL,
[AutoridadOtorgante] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[FechaOtorgada] [datetime] NOT NULL,
[TipoInstitucion] [int] NULL,
[FechaCierreEjercicio] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[TieneVigenciaPJ] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Tb_Biliotecas] ADD CONSTRAINT [PK_Tb_Biliotecas] PRIMARY KEY CLUSTERED  ([idbiblioteca]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Tb_Biliotecas] ADD CONSTRAINT [IX_Tb_Biliotecas] UNIQUE NONCLUSTERED  ([NroReconocimientoConabip]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Tb_Biliotecas] WITH NOCHECK ADD CONSTRAINT [FK_Tb_Biliotecas_tb_departamentos] FOREIGN KEY ([Departamento]) REFERENCES [dbo].[tb_departamentos] ([idDepartamento])
GO
ALTER TABLE [dbo].[Tb_Biliotecas] WITH NOCHECK ADD CONSTRAINT [FK_Tb_Biliotecas_tb_Localidades] FOREIGN KEY ([Localidad]) REFERENCES [dbo].[tb_Localidades] ([idLocalidad])
GO
ALTER TABLE [dbo].[Tb_Biliotecas] WITH NOCHECK ADD CONSTRAINT [FK_Tb_Biliotecas_tb_Provincias] FOREIGN KEY ([Provincia]) REFERENCES [dbo].[tb_Provincias] ([idProvincia])
GO
ALTER TABLE [dbo].[Tb_Biliotecas] WITH NOCHECK ADD CONSTRAINT [FK_Tb_Biliotecas_tb_SiNo] FOREIGN KEY ([TienePersoneriaJuridica]) REFERENCES [dbo].[tb_SiNo] ([Id])
GO
ALTER TABLE [dbo].[Tb_Biliotecas] WITH NOCHECK ADD CONSTRAINT [FK_Tb_Biliotecas_tb_SiNo1] FOREIGN KEY ([TieneVigenciaPJ]) REFERENCES [dbo].[tb_SiNo] ([Id])
GO
ALTER TABLE [dbo].[Tb_Biliotecas] WITH NOCHECK ADD CONSTRAINT [FK_Tb_Biliotecas_tb_TiposdeBiblioteca] FOREIGN KEY ([TipoInstitucion]) REFERENCES [dbo].[tb_TiposdeBiblioteca] ([idtipodiblioteca]) NOT FOR REPLICATION
GO
ALTER TABLE [dbo].[Tb_Biliotecas] WITH NOCHECK ADD CONSTRAINT [FK_Tb_Biliotecas_Tb_Ubicacion] FOREIGN KEY ([Ubicacion]) REFERENCES [dbo].[Tb_Ubicacion] ([idubicacion])
GO
ALTER TABLE [dbo].[Tb_Biliotecas] NOCHECK CONSTRAINT [FK_Tb_Biliotecas_tb_TiposdeBiblioteca]
GO
